<%= form_for @timeslot, :url => { :action => "search" } do |f| %>
  <% if @timeslot.errors.any? %>
    <div id="error_explanation">
      <h2><%= pluralize(@timeslot.errors.count, "error") %> prohibited this search from taking place:</h2>

      <ul>
      <% @timeslot.errors.full_messages.each do |msg| %>
        <li><%= msg %></li>
      <% end %>
      </ul>
    </div>
  <% end %>

  <div id="search_options">
    <%= radio_button_tag 'period', 'Today', true %> Today<br />
    <%= radio_button_tag 'period', 'Tomorrow' %> Tomorrow<br />
    <%= radio_button_tag 'period', 'Day after tomorrow' %> Day after tomorrow<br />
    <%= radio_button_tag 'period', '2 next days' %> 2 next days<br />
    <%= radio_button_tag 'period', '3 next days' %> 3 next days<br />
    <%= radio_button_tag 'period', '7 next days' %> 7 next days<br />
    <%= radio_button_tag 'period', '30 next days' %> 30 next days<br />
    <div id="custom">
      <%= radio_button_tag 'period', 'Custom' %>
    </div>
    <%= link_to_function "Custom", "document.getElementById('time_search').style.display = 'inherit'; document.getElementById('search_options').style.display = 'none'; document.getElementById('period_Custom').checked = true", :class => "nav_link" %>
  </div>

  <div id="time_search">
    <%= link_to_function "Predefined periods", "document.getElementById('time_search').style.display = 'none'; document.getElementById('search_options').style.display = 'inherit'; document.getElementById('period_Today').checked = true", :class => "nav_link" %>
    <div class="field">
      <%= f.label :start_time %><br />
      <%= f.date_select :start_time %>
    </div>
    <div class="field">
      <%= f.label :end_time %><br />
      <%= f.date_select :end_time %>
    </div>
  </div>
  <div class="field">
    <%= f.label :instructor %><br />
    <%= collection_select(:timeslot, :instructor, @instructors, :id, :full_name) %>
  </div>
  <div class="actions">
    <%= f.submit "Search" %>
  </div>
<% end %>
